//
//  BHSportServiceManager.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/8/26.
//

import UIKit

class BHSportServiceManager {
    
    // 打卡
    static func sportSignService(targetId: String,planId: String, handler: ((Bool,String) -> Void)?) {
        let manager = BHHTTPClient.init()
        manager.post(url: String.sport_planSign_url, paramters: ["id":targetId,"planId":planId]) { (success, errorMsg, responseDic) in
                handler?(success,errorMsg)
        }
    }
    
    // 获取打卡记录
    static func sportSignRecordListService(targetId: String, handler: ((Bool,String,[BHSportSignRecordModel]) -> Void)?) {
        let manager = BHHTTPClient.init()
        manager.get(url: String.sport_planSign_recordList_url, paramters: ["id":targetId]) { (success, errorMsg, responseDic) in
            var temp: [BHSportSignRecordModel] = []
            
            if success == true {
                let result = BHJsonTool.decodeArrayFromDic(dic: responseDic, key: "result")
                for item in result {
                    let model = BHSportSignRecordModel.init()
                    model.parseDic(item as! [String:Any])
                    temp.append(model)
                }
                
            }
            handler?(success,errorMsg,temp)
        }
    }
    
    
}
